const AccessTokenKey = 'ACCESS_TOKEN';
const RefreshTokenKey = 'REFRESH_TOKEN';
const OpenIdKey = 'OPEN_ID';
const UserCodeKey = 'USER_CODE';
const TenantIdKey = 'TENANT_ID';
const WayBillNo = 'WAY_BILL_NO';
const ExpireURL = 'EXPIRE_URL';
const CurRoute = 'CUR_ROUTE';
const NickName = 'NICK_NAME';

// TODO 需不需要REFRESH_TOKEN

// ========== Token 相关 ==========

export function getAccessToken() {
  return uni.getStorageSync(AccessTokenKey);
}

export function getRefreshToken() {
  return uni.getStorageSync(RefreshTokenKey);
}

export function getCurRoute() {
  return uni.getStorageSync(CurRoute);
}

export function setToken(token) {
  uni.setStorageSync(NickName, token.nickname);
  uni.setStorageSync(AccessTokenKey, token.accessToken);
  uni.setStorageSync(RefreshTokenKey, token.refreshToken);
}

export function removeToken() {
  uni.removeStorageSync(AccessTokenKey);
  uni.removeStorageSync(RefreshTokenKey);
}

// ========== weixin 相关 ==========
export function getOpenId() {
  return uni.getStorageSync(OpenIdKey);
}
export function setOpenId(data) {
  uni.setStorageSync(OpenIdKey, data);
}
export function removeOpenId() {
  uni.removeStorageSync(OpenIdKey);
}

export function getUserCode() {
  return uni.getStorageSync(UserCodeKey);
}
export function setUserCode(data) {
  uni.setStorageSync(UserCodeKey, data);
}
export function removeUserCode() {
  uni.removeStorageSync(UserCodeKey);
}

//租户id
export function getTenantId() {
  return uni.getStorageSync(TenantIdKey);
}
export function setTenantId(data) {
  uni.setStorageSync(TenantIdKey, data);
}
export function removeTenantId() {
  uni.removeStorageSync(TenantIdKey);
}

export function getNickName() {
  return uni.getStorageSync(NickName);
}

// PAIHAO YUNDAN BIANMA
export function getWayBillNo() {
  return uni.getStorageSync(WayBillNo);
}
export function setWayBillNo(data) {
  uni.setStorageSync(WayBillNo, data);
}
export function removeWayBillNo() {
  uni.removeStorageSync(WayBillNo);
}
